﻿namespace BathroomLocator.Services.MembershipWrappers
{
	using System;
	using System.Web.Security;

	public class RoleProviderWrapper : RoleProvider
	{
		public override string ApplicationName
		{
			get { return Roles.ApplicationName; }
			set { Roles.ApplicationName = value; }
		}

		public override void AddUsersToRoles(string[] usernames, string[] roleNames)
		{
			if (usernames.Length == 1 ||
				roleNames.Length == 1)
			{
				Roles.AddUserToRole(usernames[0], roleNames[0]);
			}
			else
			{
				Roles.AddUsersToRoles(usernames, roleNames);
			}
		}

		public override void CreateRole(string roleName)
		{
			Roles.CreateRole(roleName);
		}

		public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
		{
			return Roles.DeleteRole(roleName, throwOnPopulatedRole);
		}

		public override string[] FindUsersInRole(string roleName, string usernameToMatch)
		{
			return Roles.FindUsersInRole(roleName, usernameToMatch);
		}

		public override string[] GetAllRoles()
		{
			return Roles.GetAllRoles();
		}

		public override string[] GetRolesForUser(string username)
		{
			return Roles.GetRolesForUser(username);
		}

		public override string[] GetUsersInRole(string roleName)
		{
			return Roles.GetUsersInRole(roleName);
		}

		public override bool IsUserInRole(string username, string roleName)
		{
			return Roles.IsUserInRole(username, roleName);
		}

		public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
		{
			if (usernames.Length == 1 ||
				roleNames.Length == 1)
			{
				Roles.RemoveUsersFromRoles(usernames, roleNames);
			}
			else
			{
				Roles.RemoveUsersFromRoles(usernames, roleNames);
			}
		}

		public override bool RoleExists(string roleName)
		{
			return Roles.RoleExists(roleName);
		}
	}
}
